{include file="common/head"/}
<style>
    .layui-table-cell{height: auto;}
    .layui-table-cell ul li a{color: #1C8FEF;display: block;border: 1px solid #ececec;padding: 3px 8px;}
    .layui-table-cell ul li a:hover{color: #005580}
    element.style {
        float: left;
    }
</style>
<script src="/static/plugins/layui/layui.js" charset="utf-8"></script>

<div class="admin-main layui-anim layui-anim-upbit">
    <fieldset class="layui-elem-field layui-field-title">
        <legend>个人绩效列表</legend>
    </fieldset>
    <div class="layui-tab-content">
        <div class="layui-tab-item layui-show" style="float: left">
            <form class="layui-form" action="">
                <div style="float:left;">
                    <div class="layui-form-item" style="    margin-left: -119px;margin-top: 1px;">
                        <div class="layui-input-block" style="width: 210px;">
                            <select  class="form-control input-sm" name="status" lay-filter="cycle" aria-invalid="false" id="status1">
                                <option value="0" disabled selected style="display:none">请选择周期名称</option>
                                {volist name="cycle_data" id="vo"}
                                <option value="{$vo.id}">{$vo.title}</option>
                                {/volist}
                            </select>
                        </div>
                    </div>
                </div>

                <div style="float:left;margin-left: 20px;" class="year" hidden>
                    <div class="layui-form-item">
                        <div class="layui-input-inline"   style="margin-right: 0px">
                            <div class="layui-inline">
                                <div class="layui-input-inline">
                                    <input type="text" class="layui-input" id="year" placeholder="时间">
                                </div>
                            </div>
                        </div>
                    </div>
                </div>

                <div style="float:left;margin-left: 20px;" class="month" hidden>
                    <div class="layui-form-item">
                        <div class="layui-input-inline" style="margin-right: 0px">
                            <div class="layui-inline">
                                <div class="layui-input-inline" >
                                    <input type="text" class="layui-input" id="month" placeholder="时间">
                                </div>
                            </div>
                        </div>
                    </div>
                </div>

                <div style="float:left;margin-left: 20px;" class="xueqi" hidden>
                    <div class="layui-form-item">
                        <div class="layui-input-inline" style="margin-right: 0px">
                            <div class="layui-inline">
                                <div class="layui-input-inline" >
                                    <input type="text" class="layui-input" id="xueqi" placeholder="时间">
                                </div>
                            </div>
                        </div>
                    </div>
                </div>

                <div style="float:left;margin-left: 20px;" class="xueqi" hidden>
                    <div class="layui-form-item">
                        <div class="layui-input-inline" style="margin-right: 0px">
                            <select  class="form-control input-sm" name="xueqi_status" lay-filter="xueqi_status" aria-invalid="false" id="xueqi_status">
                                <option value="1">上学期</option>
                                <option value="2">下学期</option>
                            </select>
                        </div>
                    </div>
                </div>

                <div style="float:left;margin-left: 20px;">
                    <div class="layui-form-item">
                        <div class="layui-input-inline" style="margin-right: 0px">
                            <select  class="form-control input-sm" name="section" lay-filter="status" aria-invalid="false" id="section">
                                <option value="0" disabled selected style="display:none">请选择部门(默认全部)</option>
                                {volist name="section_data" id="vo"}
                                <option value="{$vo.section_id}">{$vo.title}</option>
                                {/volist}
                            </select>
                        </div>
                    </div>
                </div>

                <div style="float:left">
                    <div class="layui-form-item" style="margin-top: -2px;margin-left: 20px">
                        <div class="layui-input-inline" style="width: 500px;">
                            <div class="layui-inline" >
                                <div class="layui-input-inline" style="width: 200px;">
                                    <input type="text" id="teacher_keyword" name="keyword" autocomplete="off" placeholder="请输入教师姓名/教师编号" class="layui-input">
                                </div>
                            </div>
                            <div class="layui-inline" style="margin-right: 6px;">
                                <div class="layui-btn-group layui-inline" style="margin-bottom: 0px">
                                    <button id="search" class="layui-btn layui-btn-normal" type="button" lay-submit lay-filter="formDemo" style="background-color: #009688;">
                                        <i class="layui-icon">&#xe615;</i>查找
                                    </button>
                                    <button id="export" class="layui-btn layui-btn-normal" type="button" lay-filter="export" style="background-color: #009688;">
                                        导出全部
                                    </button>
                                </div>
                            </div>
                        </div>
                    </div>

                </div>
            </form>
        </div>
    </div>

    <table class="layui-table" id="list" lay-filter="list"></table>
</div>
<script>
    layui.use(['table','layer','laydate','form'], function() {
        var table = layui.table, $ = layui.jquery, laydate = layui.laydate;var form = layui.form;
        var layer = layui.layer;
        var tableIn = table.render({
            elem: '#list',
            url: "{:url('personList')}",
            method: 'post',
            page: true,
            even:true,
            cols: [[
                {field: 'teacher_no',title: '教师编号', width: 130,style:'height: auto;'},
                {field: 'true_name', title: '教师姓名', width: 100,templet:'#name'},
                {field: 'section_name', title: '部门', width: 100},
                {volist name="cate_data" id="item"}
                {field: "title{$item.cate_id}", title: '{$item.title}', width: 100},
                {/volist}
                {field: 'total_score', title: '总分', width: 100},
                {field: 'sort', title: '排名', width: 100},
            ]],
            limit: 10 //每页默认显示的数量
            ,toolbar:true
            ,defaultToolbar: ['filter', 'print', 'exports']
        });

        var cycle_cate = 0;
        form.on('select(cycle)', function(data){

            if(data.value==1){

                $('.month').show();
                $('.year').hide();
                $('.xueqi').hide();
                cycle_cate = 1;

            }else if(data.value==2){

                $('.month').hide();
                $('.year').hide();
                $('.xueqi').show();
                cycle_cate = 2;

            }else if(data.value==3){

                $('.month').hide();
                $('.year').show();
                $('.xueqi').hide();
                cycle_cate = 3;

            }
        });

        //拿到当日 年月
        var mydate = new Date();
        var year = mydate.getFullYear();
        var month = mydate.getMonth()+1;
        var cycle_1 = '';
        var cycle_2 = 1;

        laydate.render({
            elem: '#month'
            ,type: 'month'
            ,max: year+'-'+month
            ,done: function(value, date, endDate){
                cycle_1 = value;
            }
        });

        laydate.render({
            elem: '#year'
            ,type: 'year'
            ,max: year+'-01'
            ,done: function(value, date, endDate){
                cycle_1 = value;
            }
        });

        laydate.render({
            elem: '#xueqi'
            ,type: 'year'
            ,max: year+'-01'
            ,done: function(value, date, endDate){
                cycle_1 = value;
            }
        });

        //搜索
        $('#search').on('click', function () {

            //部门id
            section_id = $.trim($('#section').val());
            teacher_keywoed =  $.trim($('#teacher_keyword').val());
            cycle_2 =  $.trim($('#xueqi_status').val());


            if((section_id=='')&&(teacher_keywoed=='')&&(cycle_2=='')&&(cycle_1=='')){

                layer.msg('{:lang("pleaseEnter")}查找信息！', {icon: 0});
                return;

            }

            if(cycle_cate != 2){

                cycle_2 = '';

            }

            //表格重载
            tableIn.reload({
                //传递额外参数
                where: {section_id: section_id,teacher_keywoed:teacher_keywoed,cycle_2:cycle_2,cycle_1:cycle_1,cycle_cate:cycle_cate}
            });

        });

        //数据导出
        $(document).on('click','#export',function () {
            loading =layer.load(1, {shade: [0.1,'#fff']});
            $.post('{:url("personList")}',{all:1},function (res) {
                layer.close(loading);
                table.exportFile(tableIn.config.id, res.data,'xls');
            });
        });
    });

</script>
</body>
</html>